import { Tools } from 'weaver-mobile';
import { catchApiError, PARAMS } from '../util/index';


/*************** 协作交流 ***************/
// 协作-协作交流-列表
export const getCoworkList = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getCoworkList',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-协作交流-获取默认参与类型
export const getCoworkViewType = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getCoworkViewType',
		params
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作切换参与类型
export const coworkChangeJoinType = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/coworkChangeJoinType',
		params
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-删除协作绑定的标签
export const coworkdeleteItemLabels = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/coworkdeleteItemLabels',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

/*************** 协作详情 ***************/
// 查看协作主题内容
export const viewCowork = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/view/viewCowork',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 相关交流
export const discussRecord = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/view/discussRecord',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 相关交流
export const atList = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/view/atList',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-协作交流-置顶/取消置顶/审批/收藏/删除评论/赞 交流记录
export const coworkDiscussOperation = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/coworkDiscussOperation',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-协作交流-提交/评论/引用 交流记录
export const submitCoworkDiscuss = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/submitCoworkDiscuss',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-协作交流-标记协作类型
export const coworkMarkItemAsType = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/coworkMarkItemAsType',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-获取协作应用启用状态
export const getCoworkAppStatus = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getCoworkAppStatus',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-新建协作condition
export const coworkAddCondition = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/coworkAddCondition',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}


// 协作-保存协作
export const saveorupdateCoworkItemVo = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/saveorupdateCoworkItemVo',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-结束协作
export const batchCoworkItemMonitorEnd = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/itemMonitor/batchCoworkItemMonitorEnd',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-打开
export const coworkItemOperation = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/coworkItemOperation',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-退出
export const quitCowork = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/quitCowork',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-协作参与情况
export const getShareConditionStrList = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getShareConditionStrList',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-协作相关资源
export const getCoworkDiscussData = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getCoworkDiscussData',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-新建协作添加参与范围
export const getParterListData = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/coworkShareList',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}


// 协作-删除参与范围/添加参与人
export const saveorupdateCoworkShare = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/saveorupdateCoworkShare',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}


// 协作-参与人condition
export const getWeaAuthConditions = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getWeaAuthConditions',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-新建协作版块类型切换，取对应版块的信息以及联调属性等（如是否可匿名）
export const getNewMyCoworkTypeMapByMobile = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getNewMyCoworkTypeMapByMobile',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

/* ***************************** 标记 ********************************** */

// 协作-协作交流-获取标签设置列表
export const getCoworkLabelList = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getCoworkLabelList',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-协作交流-更新标签设置列表
export const uploadCoworkLabelList = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/uploadCoworkLabelList',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-手机端保存标签（新建都需要传，编辑只需要传前5个）
export const uploadCoworkLabelByMobile = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/uploadCoworkLabelByMobile',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-手机端新建标签condition
export const coworkLabelCondition = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/coworkLabelCondition',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

/* ***************************** 新建协作 ********************************** */

// 协作-协作交流-获取协作附件目录
export const getCoworkAccessory = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getCoworkAccessory',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-参与的协作-列表
export const getCoworkHrmViewList = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/getCoworkHrmViewList',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-已退出人员-列表
export const coworkQuitList = params => {
	let options = {
		method: 'GET',
		url: '/api/cowork/base/coworkQuitList',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}

// 协作-重新加入协作
export const reJoinCoworkQuiter = params => {
	let options = {
		method: 'POST',
		url: '/api/cowork/base/reJoinCoworkQuiter',
		params: {...PARAMS, ...params}
	};
	return Tools.callApi(options).then(catchApiError);
}